<?php
namespace app\api\controller\comv1;
class Com extends Base
{
    //获取配置
    public function getsys(){
        //suc([]);
        //suc(['token'=>'123']);
        //suc(['token'=>[1,2,3]]);
        suc(['token'=>['a'=>1]]);
        $d = $this->post;
        $key = explode(",",$d['key']);
        $rs = [];
        foreach($key as $v){
            $rs[$v] = c("type.{$d['key']}");
        }
        return suc($rs);
    }

    //删除购物车商品
    public function getinfo(){
        $token = $this->post('token');
        $userinfo = [];
        if($token){
            $userinfo = $this->db->query("select * from user where wap_token=?",[$token],1);
        }
        if(!$userinfo){
            if(is_ajax()){
                err('请先登录!');
            }
        }
        suc(["userinfo"=>$userinfo]);
    }

    //
    public function getWord(){
        $word = $this->db->cache("select * from word");
        foreach ($word as $key => $val) {
            $val['h5_url'] = url('h5/getword',['id'=>$val['id']]);
            $word[$val['uuid']] = $val;
            unset($word[$key]);
        }
        suc(["word"=>$word]);
    }

    //获取子地区名称
    public function getComAddress(){
        $pid = $this->post('pid') ? $this->post('pid') : $this->get('pid');
        $rs = $this->db->query('select id,name from com_address where parent_id=?',[$pid]);
        suc($rs);
    }
}
